package com.metel.mservice.common.listener;

import javax.servlet.ServletContextEvent;

import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import com.metel.mservice.common.context.ContextUtil;

/**
 * 직접 Spring Beans 에 접근할 수 있도록 WebApplicationContext 저장
 * @author iamnow
 *
 */
public class CustomContextLoaderListener extends ContextLoaderListener{

	@Override
	public void contextInitialized(ServletContextEvent event) {
		super.contextInitialized(event);
		
		WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(event.getServletContext());
		ContextUtil.setContext(context);		
	}
}
